package com.java2207.group1.controller;

import com.github.pagehelper.PageHelper;
import com.java2207.group1.common.LayuiPageVo;
import com.java2207.group1.common.R;
import com.java2207.group1.pojo.Fault;
import com.java2207.group1.service.FaultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/fault")
public class FaultController {

    @Autowired
    private FaultService faultService;

    @RequestMapping("/faultPageAll")
    public LayuiPageVo<Fault> faultPageAll(@RequestParam Map<String,Object> map){
        LayuiPageVo<Fault> layuiPageVo = faultService.faultPageAll(map);
        return layuiPageVo;
    }
    @RequestMapping("/delectFault")
    public R delectFault(int id ){
        int i = faultService.delectFault(id);
        if (i!=0){
            return  R.ok();
        }
        return  R.error();
    }
    @RequestMapping("/updateFault")
    public R updateFault(Fault fault){
        int i = faultService.updateFault(fault);
        if (i!=0){
            return  R.ok();
        }
        return  R.error();
    }
    @RequestMapping("/addFault")
    public  R addFault(Fault fault){
        int i = faultService.addFault(fault);
        if (i!=0){
            return  R.ok();
        }
        return  R.error();
    }

}
